﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Dominio;

namespace Persistencia
{
    public class Piso_Data
    {
        SqlConnection _cn = null;
        SqlCommand _cmd = null;
        SqlDataReader _reader = null;

        public List<Piso> Data_Piso_List()
        {
            using (_cn = new SqlConnection(Helpers.ConexionUtil.ObtenerCadena()))
            {
                using (_cmd = new SqlCommand("USP_PISO_LIST", _cn))
                {
                    List<Piso> _ListPiso = new List<Piso>();
                    _cn.Open();
                    _cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    _reader = _cmd.ExecuteReader();

                    while (_reader.Read())
                    {
                        Piso _piso = new Piso();

                        _piso.coPiso = Convert.ToInt32(_reader["coPiso"].ToString());
                        _piso.noPiso = _reader["noPiso"].ToString();

                        _ListPiso.Add(_piso);
                    }
                    return _ListPiso;
                }
            }
        }
    }
}
